﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using Assist;
using Autodesk.Revit.UI;
using YArchitech.Controls;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;
using YJKRevitBase.WinForm.WinFormRemindSuit;
using YJKRevitKernel.FormUtility;
using YJKCopyModel.DuctFastModel;

namespace YJKCopyModel.Forms
{
	public partial class NextDuctFastmodelForm : System.Windows.Forms.Form
	{
		public CloseDuctDlgType DlgCloseType
		{
			get
			{
				return this.m_DlgCloseType;
			}
		}

		public NextDuctFastmodelForm(UIDocument inputUIDoc)
		{
			this.InitializeComponent();
			this.m_uiDoc = inputUIDoc;
			this.m_DlgCloseType = CloseDuctDlgType.Other;
		}

		private void btnNextCancel_Click(object sender, EventArgs e)
		{
			base.DialogResult = DialogResult.Cancel;
		}

		private void btnNextOK_Click(object sender, EventArgs e)
		{
			DuctFormData.m_strSystemType = this.cmbSystemType.Text;
			DuctFormData.m_strDuctType = this.cmbDuctType.Text;
			DuctFormData.m_strAlignType = this.cmbAlignType.Text;
			DuctFormData.m_strLevel = this.nUpDownLevel.Text;
			DuctFormData.m_bIsDrawCircle = this.chkDrawCircle.Checked;
			bool @checked = this.radLevelChange.Checked;
			if (@checked)
			{
				this.m_DlgCloseType = CloseDuctDlgType.LevelFastModel;
			}
			else
			{
				bool checked2 = this.radBlockChange.Checked;
				if (checked2)
				{
					this.m_DlgCloseType = CloseDuctDlgType.AreaFastModel;
				}
				else
				{
					bool checked3 = this.radSystemChange.Checked;
					if (checked3)
					{
						this.m_DlgCloseType = CloseDuctDlgType.SystemFastModel;
					}
				}
			}
			base.DialogResult = DialogResult.OK;
		}

		private void radSystemChange_CheckedChanged(object sender, EventArgs e)
		{
			bool @checked = this.radSystemChange.Checked;
			if (@checked)
			{
				DuctFormData.m_bIsSelect = false;
				DuctFormData.m_bIsSystem = true;
				DuctFormData.m_bIsLevel = false;
				this.radBlockChange.Checked = false;
				this.radLevelChange.Checked = false;
			}
		}

		private void radBlockChange_CheckedChanged(object sender, EventArgs e)
		{
			bool @checked = this.radBlockChange.Checked;
			if (@checked)
			{
				DuctFormData.m_bIsSelect = true;
				DuctFormData.m_bIsSystem = false;
				DuctFormData.m_bIsLevel = false;
				this.radSystemChange.Checked = false;
				this.radLevelChange.Checked = false;
			}
		}

		private void radLevelChange_CheckedChanged(object sender, EventArgs e)
		{
			bool @checked = this.radLevelChange.Checked;
			if (@checked)
			{
				DuctFormData.m_bIsSelect = false;
				DuctFormData.m_bIsSystem = false;
				DuctFormData.m_bIsLevel = true;
				this.radSystemChange.Checked = false;
				this.radBlockChange.Checked = false;
			}
		}

		private void NextDuctFastmodelForm_Load(object sender, EventArgs e)
		{
			//base.Icon = Resource.YArchitechIcon;
			DuctFormData.m_SysType = GetRevitProjectData.GetAllDuctSystem(this.m_uiDoc.Document);
			List<string> list = DuctFormData.m_SysType.Keys.ToList<string>();
			this.cmbSystemType.Items.AddRange(list.ToArray());
			bool flag = list.Count > 0;
			if (flag)
			{
				this.cmbSystemType.SelectedIndex = 0;
			}
			DuctFormData.m_DuctType = GetRevitProjectData.GetAllDuctType(this.m_uiDoc.Document);
			List<string> list2 = DuctFormData.m_DuctType.Keys.ToList<string>();
			string text = string.Empty;
			foreach (string text2 in list2)
			{
				bool flag2 = text2.Contains("矩形") && text2.Contains("镀锌钢板_法兰");
				if (flag2)
				{
					text = text2;
				}
			}
			bool flag3 = list2.Count > 0;
			if (flag3)
			{
				this.cmbDuctType.Items.AddRange(list2.ToArray());
				bool flag4 = text != string.Empty;
				if (flag4)
				{
					this.cmbDuctType.Text = text;
				}
				else
				{
					this.cmbDuctType.SelectedIndex = 0;
				}
			}
			foreach (string item in DataEnum.DuctAlign())
			{
				this.cmbAlignType.Items.Add(item);
			}
			this.cmbAlignType.SelectedIndex = 2;
			bool bIsSelect = DuctFormData.m_bIsSelect;
			if (bIsSelect)
			{
				this.radBlockChange.Checked = true;
			}
			else
			{
				bool bIsLevel = DuctFormData.m_bIsLevel;
				if (bIsLevel)
				{
					this.radLevelChange.Checked = true;
				}
				else
				{
					this.radSystemChange.Checked = true;
				}
			}
			this.AddControlGroup();
			this.m_ControlInfoManager = new ControlInfoManager(this, this.m_lstControlGroup, null, null);
			this.m_ControlInfoManager.SetControlInfoToForm();
			this.bIsNew = false;
		}

		private void NextDuctFastmodelForm_FormClosed(object sender, FormClosedEventArgs e)
		{
			bool flag = this.m_ControlInfoManager != null;
			if (flag)
			{
				this.m_ControlInfoManager.GetControlInfoToXml();
			}
		}

		private void AddControlGroup()
		{
			ControlPacker controlPacker = new ControlPacker();
			controlPacker.UseControl = this;
			this.m_lstControlGroup.Add(new KeyValuePair<ControlPacker, bool>(controlPacker, false));
			controlPacker = new ControlPacker();
			controlPacker.UseControl = this.cmbSystemType;
			this.m_lstControlGroup.Add(new KeyValuePair<ControlPacker, bool>(controlPacker, false));
			controlPacker = new ControlPacker();
			controlPacker.UseControl = this.cmbDuctType;
			this.m_lstControlGroup.Add(new KeyValuePair<ControlPacker, bool>(controlPacker, false));
			controlPacker = new ControlPacker();
			controlPacker.UseControl = this.cmbAlignType;
			this.m_lstControlGroup.Add(new KeyValuePair<ControlPacker, bool>(controlPacker, false));
			controlPacker = new ControlPacker();
			controlPacker.UseControl = this.radSystemChange;
			this.m_lstControlGroup.Add(new KeyValuePair<ControlPacker, bool>(controlPacker, false));
			controlPacker = new ControlPacker();
			controlPacker.UseControl = this.radBlockChange;
			this.m_lstControlGroup.Add(new KeyValuePair<ControlPacker, bool>(controlPacker, false));
			controlPacker = new ControlPacker();
			controlPacker.UseControl = this.radLevelChange;
			this.m_lstControlGroup.Add(new KeyValuePair<ControlPacker, bool>(controlPacker, false));
			controlPacker = new ControlPacker();
			controlPacker.UseControl = this.chkDrawCircle;
			this.m_lstControlGroup.Add(new KeyValuePair<ControlPacker, bool>(controlPacker, false));
			controlPacker = new ControlPacker();
			controlPacker.UseControl = this.nUpDownLevel;
			controlPacker.UseCustomFormatter = new FormRemember();
			this.m_lstControlGroup.Add(new KeyValuePair<ControlPacker, bool>(controlPacker, false));
		}

		private void NextDuctFastmodelForm_KeyDown(object sender, KeyEventArgs e)
		{
			bool flag = e.KeyValue == 27;
			if (flag)
			{
				base.Close();
			}
		}

		private void nUpDownLevel_ValueChanged(object sender, EventArgs e)
		{
			bool flag = Convert.ToDouble(this.nUpDownLevel.Text) < 0.0;
			if (flag)
			{
				YJKMessageBox.Show("相对标高为正数！");
			}
		}

		private void chkDrawCircle_CheckedChanged(object sender, EventArgs e)
		{
			bool @checked = this.chkDrawCircle.Checked;
			if (@checked)
			{
				DuctFormData.m_bIsDrawCircle = true;
			}
			else
			{
				DuctFormData.m_bIsDrawCircle = false;
			}
		}

		private bool bIsNew = true;

		private CloseDuctDlgType m_DlgCloseType;

		private ControlInfoManager m_ControlInfoManager = null;

		private List<KeyValuePair<ControlPacker, bool>> m_lstControlGroup = new List<KeyValuePair<ControlPacker, bool>>();

		private UIDocument m_uiDoc = null;
	}
}
